<?php
//读取今日预订的场地数量
$conditions = explode(' ', $findText);
$itemData = array();
foreach ($conditions as $value) {
    $textList = explode('<', $value);
    $count = count($textList);
    if ($count == 2) {
        $itemData[$textList[0]] = '<' . $textList[1];
        continue;
    }
    $textList = explode('>', $value);
    $count = count($textList);
    if ($count == 2) {
        $itemData[$textList[0]] = '>' . $textList[1];
        continue;
    }
    $textList = explode('=', $value);
    $count = count($textList);
    if ($count == 2) {
        $itemData[$textList[0]] = $textList[1];
    }
    if ($count == 1) {
        array_push($itemData, $value);
    }
}
$paidTime = str_replace('>', '', $itemData['paidTime']);
$paidTime = str_replace('<', '', $paidTime);
$paidTime = str_replace('=', '', $paidTime);
$paidTime = intval($paidTime);
$dayBegin = strtotime(date('Y-m-d',$paidTime).' 00:00:00');
$dayEnd = $dayBegin + 60 * 60 * 24;
$cart = new BWCart();
$view = $cart->getView(array('itemData' => $itemData));?>
<meta name="viewport" contdent="initial-scale=1, width=device-width, maximum-scale=1, user-scalable=no">
<meta name="viewport" content="initial-scale=1.0,user-scalable=no,maximum-scale=1" media="(device-height: 568px)">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-touch-fullscreen" content="yes">
<meta name="full-screen" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="format-detection" content="telephone=no">
<style type="text/css">
.nav-dropdown ul {margin: 0;}
    .nav-dropdown ul li {
    height: 30px;
    line-height: 30px;
}
.btn-d{
    height: 30px;
    padding: 3px 12px;
    background-color: white;
    border: 1px solid #2bb2a3;
    color: #2bb2a3;
}
</style>
<script type="text/javascript">
$(".nav-dropdown-btn").click(function() {
    $("#nav-dropdown").toggle();
});
</script>
<body>
    <header class="navbar" style="min-height:52px;margin:0px;">
        <table style="width:100%;">
            <tr>
                <td style="width:10%;text-align:left;">
                    <div style="margin-top:8px;margin-left:10px;"><?php
                        echo $control->getAjaxLink(array(
                            'name' => '<img src="'.Yii::app()->request->baseUrl.'/images/mobile/backbtn.png'.'" />', 
                            'id' => 'manageBooking'), array(
                            'htmlOptions' => array(
                            'enctype' => 'multipart/form-data'
                        )));?> 
                    </div>
                </td>
                <td style="width:80%;text-align:center;"><h4 style="margin-top:15px;"><?php echo $flagText;?></h4></td>
                <td style="width:10%;text-align:right;">
                    <div class="nav-wrap-right">
                        <a class="react nav-dropdown-btn" style="width:30px;margin-right:8px;">
                            <span class="nav-btn">
                                <i class="text-icon"><img src="<?php echo Yii::app()->request->baseUrl.'/images/mobile/wave.png';?>" /></i>导航
                            </span>
                        </a>
                    </div>           
                    <div id="nav-dropdown" class="nav-dropdown" style="top:52px;width:100px;">
                        <ul>
                            <li><?php
                                echo $control->getAjaxLink(array('name' => '首页', 'id' => 'manageBooking'), array(
                                    'htmlOptions'=>array(
                                    'class'=>'react',
                                    'enctype'=>'multipart/form-data'
                                )));?> 
                            </li>
                            <li><?php
                                echo $control->getAjaxLink(array('name' => '选择日期', 'id' => 'manageBooking_selectTime'), array(
                                    'findText'=>$findText,
                                    'flagText'=>$flagText,
                                    'backPage'=>'manageBooking_bookingList',
                                    'htmlOptions'=>array(
                                    'class'=>'react',
                                    'enctype'=>'multipart/form-data'
                                )));?></li>
                        </ul>
                   </div>
                </td>
            </tr>
        </table>
        <div id="ajax-loaderdiv" style="position: fixed;top: 0;left: 0;width: 100%;height: 100%;z-index: 35000;background-color: rgba(0, 0, 0, 0.3);display: none;">
            <img src="/billyn-dev/images/ajax-loader.gif" class="ajax-loader"style="position: absolute;left: 50%;top: 50%;margin-left: -16px;margin-top: -16px;display: block;"/>
        </div>
    </header>
    <dl class="list" style="margin:0px;"><?php
        if(count($view)) {
            foreach ($view as $cartList) {
                if ($cartList instanceof BTreeList) {
                    $paidTime = $cartList->getItem('paidTime')->value;
                    if($paidTime>=$dayBegin && $paidTime<=$dayEnd) {
                        $cartId = $cartList->getId();
                        $price = $cartList->getItem('price')->value;
                        $unit = $cartList->getItem('moneyUnit')->value;
                        $quantity = $cartList->getItem('quantity')->value;
                        $productName = $cartList->getItem('productName')->value;
                        $productId = $cartList->getItem('productId')->value;

                        $bookingItem = new BWInputValue($productId);
                        $bookingRow = new BTreeList($bookingItem);
                        $venderName = $bookingRow->getItem('venderName')->value;
                        $courtDisplayName = $bookingRow->getItem('courtDisplayName')->value;
                        $courtAddress = $bookingRow->getItem('courtAddress')->value;
                        $courtName = $bookingRow->getItem('courtName')->value;
                        $startTime = $bookingRow->getItem('startTime')->value;
                        $endTime = $bookingRow->getItem('endTime')->value;?>
                        <dd style="position:relative;padding-left:10px;">
                            <a href="#">
                            <div class="react" style="padding-top: 10px;padding-bottom: 6px;">
                                <span style="color:#2BB2A3;font-weight:bold;display:inline-block;margin-bottom:6px;"><?php echo '流水号：'.$cartId;?></span>
                                <br/>
                                    <span class="time" style="display: inline-block;margin-bottom: 6px;color:black;">
                                        <i class="text-icon" style="font-family: inherit;"><span class="booking_date"><?php echo '场地名：'.$courtDisplayName;?></i>
                                    </span>
                                <br/>
                                <span style="display: inline-block;margin-bottom: 6px;color:#FDB338;font-size: 13px;"><?php echo date('Y-m-d H:i:s',$startTime).'-'.date('H:i:s',$endTime);?></span>
                                <br/>
                                <span class="" style="display: inline-block;margin-bottom: 6px;color:gray;font-size:.5rem;">
                                    <?php echo '地点：'.$courtAddress; ?>
                                </span>
                            </div>
                            </a>
                            <div class="right_btn" style="position:absolute;right:10px;top:45%;">
                                <span class="line-right">
                                    <?php
                                    echo $control->getAjaxLink(array('name' => '查看', 'id' => 'manageBooking_bookingDetail'), array(
                                        'findText'=>$findText,
                                        'flagText'=>$flagText,
                                        'cartId'=>$cartId,
                                        'bookingId'=>$productId,
                                        'htmlOptions'=>array(
                                        'enctype'=>'multipart/form-data',
                                        'class'=>'btn btn-d'
                                    )));
                                    ?> 
                                </span>
                            </div>
                        </dd><?php 
            }}} 
        } else {?>
            <div style="height:200px;background-color:#FCFCFC;color:chocolate;text-align:center;padding-top:100px;">
                暂无已预定场地！
            </div><?php 
        }?>
    </dl>
    <footer>
        <div class="footer-copyright">
            <div class="hr"></div>
            <span class="footer-copyright-text">
                Copyright © 2014 billyn.net </span>
        </div>
    </footer>
</body>